<?php

namespace App\Http\Controllers\CRM\MiniAPP;

use App\Helper\ApiResponseHelper;
use App\Http\Controllers\Controller;
use App\Http\Requests\CRM\MiniAPP\DuelTypeRequest;
use App\Http\Resources\CRM\MiniAPP\DuelTypeResource;
use App\Models\DuelType;
use Illuminate\Http\Request;

class DuelTypeController extends Controller
{
    public function getList()
    {
        $types = DuelType::latest()->get();

        return DuelTypeResource::collection($types);
    }

    public function create(DuelTypeRequest $request)
    {
        $type = DuelType::create($request->only([
            'name'
        ]));

        return new DuelTypeResource($type);
    }

    public function remove(DuelType $type)
    {
        $type->delete();

        return ApiResponseHelper::json([]);
    }
}
